package com.control;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.Dept;
import com.emp.database.EmpOperate;

/**
 * Servlet implementation class ManagerDept
 */
@WebServlet("/ManagerDept")
public class ManagerDept extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ManagerDept() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		int currentPage= request.getParameter("currentPage")==null ? 1 : Integer.parseInt(request.getParameter("currentPage"));
		EmpOperate eo = new EmpOperate();
		
		int pageRow=4;
		int lasePage=eo.getLastPage2(pageRow);
		
		List<Dept> delist= eo.getAllDept(currentPage, pageRow);
		
		request.setAttribute("delist", delist);
		request.setAttribute("lasePage", lasePage);
		request.setAttribute("currentPage", currentPage);
		
		request.getRequestDispatcher("dept/dept.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
